package com.kmxd.ams.core.common.enums;

import com.kmxd.ams.core.common.constant.ErrorCode;
import com.kmxd.ams.core.exception.BizException;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 目录类型
 *
 * @author admin
 */
@Getter
@AllArgsConstructor
public enum CatalogTypeEnum {

  /** 数据节点 */
  CONDITION_NODE(1, "数据节点"),
  /** 分组节点 */
  GROUP_NODE(2, "分组节点"),
  DIR_NODE(3, "目录"),
  ARCH_NODE(4, "门类"),
  ARCH_MODEL_NODE(5, "档案类型"),
  ;

  private int code;
  private String desc;

  public static CatalogTypeEnum convert(int code) {
    return Arrays.stream(values())
        .filter(x -> x.code == code)
        .findAny()
        .orElseThrow(() -> BizException.instance(ErrorCode.NOT_FOUND, "未找到档案状态：" + code));
  }
}
